package com.luoxue.execsql.rest.config.handler;

import com.luoxue.execsql.common.util.MyStringUtil;
import com.luoxue.execsql.common.util.ResultBody;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler(Exception.class)
    public ResultBody globalException(Exception e) {
        e.printStackTrace();
        return ResultBody.error(MyStringUtil.getValue(e.getMessage(), e.toString()));
    }
}
